package microcredit.gui.base;

import java.awt.Cursor;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import java.awt.Window;

import javax.swing.JDialog;

public class BaseDialog extends JDialog implements IBaseWindow {

	private static final long serialVersionUID = 1L;

//	private final RightClick rightClick = new RightClick(getContentPane());
	
	public BaseDialog() {
		super();
		initialize();
	}

	public BaseDialog(Dialog owner, boolean modal) {
		super(owner, modal);
		initialize();
	}

	public BaseDialog(Dialog owner, String title, boolean modal,
			GraphicsConfiguration gc) {
		super(owner, title, modal, gc);
		initialize();
	}

	public BaseDialog(Dialog owner, String title, boolean modal) {
		super(owner, title, modal);
		initialize();
	}

	public BaseDialog(Dialog owner, String title) {
		super(owner, title);
		initialize();
	}

	public BaseDialog(Dialog owner) {
		super(owner);
		initialize();
	}

	public BaseDialog(Frame owner, boolean modal) {
		super(owner, modal);
		initialize();
	}

	public BaseDialog(Frame owner, String title, boolean modal,
			GraphicsConfiguration gc) {
		super(owner, title, modal, gc);
		initialize();
	}

	public BaseDialog(Frame owner, String title, boolean modal) {
		super(owner, title, modal);
		initialize();
	}

	public BaseDialog(Frame owner, String title) {
		super(owner, title);
		initialize();
	}

	public BaseDialog(Frame owner) {
		super(owner);
		initialize();
	}

	public BaseDialog(Window owner, ModalityType modalityType) {
		super(owner, modalityType);
		initialize();
	}

	public BaseDialog(Window owner, String title, ModalityType modalityType,
			GraphicsConfiguration gc) {
		super(owner, title, modalityType, gc);
		initialize();
	}

	public BaseDialog(Window owner, String title, ModalityType modalityType) {
		super(owner, title, modalityType);
		initialize();
	}

	public BaseDialog(Window owner, String title) {
		super(owner, title);
		initialize();
	}

	public BaseDialog(Window owner) {
		super(owner);
		initialize();
	}

	private void initialize() {
//		setGlassPane(rightClick);
//		rightClick.setVisible(true);
//		rightClick.setEnabled(false);
	}
	
	@Override
	public void setLoadingState(boolean loading) {
		setLoadingStateImpl(this, loading);
	}

	static void setLoadingStateImpl(JDialog w, boolean loading) {
		Cursor c;
		if (loading) {
			c = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
		} else {
			c = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
		}
		w.setCursor(c);
		w.getRootPane().setCursor(c);
		w.getContentPane().setCursor(c);
		w.getLayeredPane().setCursor(c);
		w.getGlassPane().setCursor(c);
	}

}
